package cn.ddd.linktran.infrastructure.record.gateway;

import cn.ddd.linktran.domain.domainobject.TransformEventRecordDO;
import cn.ddd.linktran.domain.domainobject.VisitStatisticsDO;
import cn.ddd.linktran.domain.gateway.TransformEventRecordGateWay;
import cn.ddd.linktran.infrastructure.record.convertor.TransformEventRecordConvertor;
import cn.ddd.linktran.infrastructure.record.mapper.TransformEventRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.time.OffsetDateTime;
import java.util.List;

@Repository
public class TransformEventRecordGateWayImpl implements TransformEventRecordGateWay {
    @Autowired
    private TransformEventRecordMapper transformEventRecordMapper;
    @Autowired
    private TransformEventRecordConvertor transformEventRecordConvertor;
    @Override
    public void insertTransformEventRecordDO(TransformEventRecordDO transformEventRecordDO) {
        transformEventRecordMapper.insert(transformEventRecordConvertor.toPO(transformEventRecordDO));
    }

    @Override
    public List<VisitStatisticsDO> getVisitStatisticsDuration(OffsetDateTime start, OffsetDateTime end) {

        return transformEventRecordMapper.selectVisitStatisticsDuration(start, end);
    }
}
